home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / vgakit52.zip / BANKS.ASM next >
Assembly Source File  |  1992-10-21  |  21KB  |  1,242 lines

  1.  
  2.     include    model.inc
  3.     include    vesa.inc
  4. ;
  5. ;    VGAKIT Version 5.2b
  6. ;
  7. ;    Copyright 1988,89,90,91,92 John Bridges
  8. ;    Free for use in commercial, shareware or freeware applications
  9. ;
  10. ;    BANKS.ASM
  11. ;
  12. .data?
  13.  
  14.     public    curbk
  15.  
  16. curbk    dw    ?
  17.  
  18.     public    vgamem,bksize
  19.  
  20. vgamem    dw    ?        ;amount of memory on VGA card in K
  21. bksize    dw    ?        ;size of memory banks in K
  22.  
  23.     public    cirrus,everex,acumos,paradise,tseng,trident,t8900
  24.     public    ativga,aheada,aheadb,oaktech,video7
  25.     public    chipstech,tseng4,genoa,ncr,compaq,vesa,dactype
  26.  
  27. cirrus    dw    ?
  28. everex    dw    ?
  29. acumos    dw    ?
  30. paradise dw    ?
  31. tseng    dw    ?
  32. trident    dw    ?
  33. t8900    dw    ?
  34. ativga    dw    ?
  35. aheada    dw    ?
  36. aheadb    dw    ?
  37. oaktech    dw    ?        ;Oak Technology Inc OTI-067 and OTI-077
  38. video7    dw    ?
  39. chipstech dw    ?
  40. tseng4    dw    ?
  41. genoa    dw    ?
  42. ncr    dw    ?
  43. compaq    dw    ?
  44. vesa    dw    ?
  45.  
  46. dactype    dw    ?        ; 0 = Normal DAC
  47.                 ; 1 = Sierra SC11481, SC11486, SC11488
  48.                 ; 2 = Sierra SC11485, SC11487, SC11489
  49.                 ; 3 = AT&T ATT20C491
  50.                 ; 4 = ACUMOS ADAC1
  51.  
  52. first    dw    ?        ;flag so whichvga() is only called once
  53. retval    dw    ?        ;first return value from whichvga()
  54.  
  55. .data
  56.  
  57. OSEG    equ    DS:        ;segment override for variable access
  58.  
  59.     public    bankadr
  60.  
  61. if @Codesize
  62. bankadr    dw    offset _nobank
  63.     dw    seg _nobank
  64. else
  65. bankadr    dw    offset _nobank
  66. endif
  67.  
  68.     public    vesafunc
  69.  
  70. vesafunc dw    0
  71.     dw    0
  72.  
  73. vesamodes label word
  74.     dw    100h,     640, 400, 8
  75.     dw    101h,     640, 480, 8
  76.     dw    102h,     800, 600, 4
  77.     dw    103h,     800, 600, 8
  78.     dw    104h,    1024, 768, 4
  79.     dw    105h,    1024, 768, 8
  80.     dw    106h,    1280,1024, 4
  81.     dw    107h,    1280,1024, 8
  82.     dw    10Dh,     320, 200,16
  83.     dw    10Eh,     320, 200,16
  84.     dw    10Fh,     320, 200,24
  85.     dw    110h,     640, 480,16
  86.     dw    111h,     640, 480,16
  87.     dw    112h,     640, 480,24
  88.     dw    113h,     800, 600,16
  89.     dw    114h,     800, 600,16
  90.     dw    115h,     800, 600,24
  91.     dw    116h,    1024, 768,16
  92.     dw    117h,    1024, 768,16
  93.     dw    118h,    1024, 768,24
  94.     dw    119h,    1280,1024,16
  95.     dw    11Ah,    1280,1024,16
  96.     dw    11Bh,    1280,1024,24
  97.     dw    0
  98. .code
  99.  
  100.     public    newbank
  101.     public    whichvga
  102.  
  103. newbank    proc            ;bank number is in AX
  104. if @Codesize
  105.     jmp    dword ptr OSEG[bankadr]
  106. else
  107.     jmp    OSEG[bankadr]
  108. endif
  109.  
  110. _tseng::            ;Tseng 3000 series
  111.     push    ax
  112.     push    dx
  113.     cli
  114.     mov    OSEG[curbk],ax
  115.     and    al,7
  116.     mov    ah,al
  117.     shl    al,1
  118.     shl    al,1
  119.     shl    al,1
  120.     or    al,ah
  121.     or    al,01000000b
  122.     mov    dx,3cdh
  123.     out    dx,al
  124.     sti
  125.     pop    dx
  126.     pop    ax
  127.     ret
  128.  
  129.  
  130. _tseng4::            ;Tseng 4000 series
  131.     push    ax
  132.     push    dx
  133.     cli
  134.     mov    OSEG[curbk],ax
  135.     mov    ah,al
  136.     mov    dx,3bfh        ;Enable access to extended registers
  137.     mov    al,3
  138.     out    dx,al
  139.     mov    dl,0d8h
  140.     mov    al,0a0h
  141.     out    dx,al
  142.     and    ah,15
  143.     mov    al,ah
  144.     shl    al,1
  145.     shl    al,1
  146.     shl    al,1
  147.     shl    al,1
  148.     or    al,ah
  149.     mov    dl,0cdh
  150.     out    dx,al
  151.     sti
  152.     pop    dx
  153.     pop    ax
  154.     ret
  155.  
  156.  
  157. _trident::            ;Trident
  158.     push    ax
  159.     push    dx
  160.     push    ax
  161.     cli
  162.     mov    OSEG[curbk],ax
  163.     mov    dx,3ceh        ;set pagesize to 64k
  164.     mov    al,6
  165.     out    dx,al
  166.     inc    dl
  167.     in    al,dx
  168.     dec    dl
  169.     or    al,4
  170.     mov    ah,al
  171.     mov    al,6
  172.     out    dx,ax
  173.  
  174.     mov    dl,0c4h        ;switch to BPS mode
  175.     mov    al,0bh
  176.     out    dx,al
  177.     inc    dl
  178.     in    al,dx
  179.     dec    dl
  180.  
  181.     pop    ax
  182.     mov    ah,al
  183.     xor    ah,2
  184.     mov    dx,3c4h
  185.     mov    al,0eh
  186.     out    dx,ax
  187.     sti
  188.     pop    dx
  189.     pop    ax
  190.     ret
  191.  
  192.  
  193. _video7::            ;Video 7
  194.     push    ax
  195.     push    dx
  196.     push    cx
  197.     cli
  198.     mov    OSEG[curbk],ax
  199.     and    ax,15
  200.     mov    ch,al
  201.     mov    dx,3c4h
  202.     mov    ax,0ea06h
  203.     out    dx,ax
  204.     mov    ah,ch
  205.     and    ah,1
  206.     mov    al,0f9h
  207.     out    dx,ax
  208.     mov    al,ch
  209.     and    al,1100b
  210.     mov    ah,al
  211.     shr    ah,1
  212.     shr    ah,1
  213.     or    ah,al
  214.     mov    al,0f6h
  215.     out    dx,al
  216.     inc    dx
  217.     in    al,dx
  218.     dec    dx
  219.     and    al,not 1111b
  220.     or    ah,al
  221.     mov    al,0f6h
  222.     out    dx,ax
  223.     mov    ah,ch
  224.     mov    cl,4
  225.     shl    ah,cl
  226.     and    ah,100000b
  227.     mov    dl,0cch
  228.     in    al,dx
  229.     mov    dl,0c2h
  230.     and    al,not 100000b
  231.     or    al,ah
  232.     out    dx,al
  233.     sti
  234.     pop    cx
  235.     pop    dx
  236.     pop    ax
  237.     ret
  238.  
  239.  
  240. _paradise::            ;Paradise
  241.     push    ax
  242.     push    dx
  243.     push    ax
  244.     cli
  245.     mov    OSEG[curbk],ax
  246.     mov    dx,3ceh
  247.     mov    ax,50fh        ;turn off write protect on VGA registers
  248.     out    dx,ax
  249.     pop    ax
  250.     mov    ah,al
  251.     mov    al,9
  252.     out    dx,ax
  253.     sti
  254.     pop    dx
  255.     pop    ax
  256.     ret
  257.  
  258. _acumos::            ;AcuMos
  259.     push    ax
  260.     push    dx
  261.     push    ax
  262.     cli
  263.     mov    OSEG[curbk],ax
  264.     mov    dx,3c4h        ;Sequencer index 6
  265.     mov    ax,1206h    ;turn off write protect on VGA registers
  266.     out    dx,ax
  267.     mov    dx,3ceh
  268.     pop    ax
  269.     mov    ah,al
  270.     mov    al,9
  271.     out    dx,ax
  272.     sti
  273.     pop    dx
  274.     pop    ax
  275.     ret
  276.  
  277.  
  278. _chipstech::            ;Chips & Tech
  279.     push    ax
  280.     push    dx
  281.     push    ax
  282.     cli
  283.     mov    OSEG[curbk],ax
  284.     mov    dx,46e8h    ;place chip in setup mode
  285.     mov    ax,1eh
  286.     out    dx,ax
  287.     mov    dx,103h        ;enable extended registers
  288.     mov    ax,0080h
  289.     out    dx,ax
  290.     mov    dx,46e8h    ;bring chip out of setup mode
  291.     mov    ax,0eh
  292.     out    dx,ax
  293.     pop    ax
  294.     mov    ah,al
  295.     mov    al,10h
  296.     mov    dx,3d6h
  297.     out    dx,ax
  298.     sti
  299.     pop    dx
  300.     pop    ax
  301.     ret
  302.  
  303.  
  304. _ativga::            ;ATI VGA Wonder
  305.     push    ax
  306.     push    dx
  307.     cli
  308.     mov    OSEG[curbk],ax
  309.     mov    ah,al
  310.     mov    dx,1ceh
  311.     mov    al,0b2h
  312.     out    dx,al
  313.     inc    dl
  314.     in    al,dx
  315.     shl    ah,1
  316.     and    al,0e1h
  317.     or    ah,al
  318.     mov    al,0b2h
  319.     dec    dl
  320.     out    dx,ax
  321.     sti
  322.     pop    dx
  323.     pop    ax
  324.     ret
  325.  
  326.  
  327. _everex::            ;Everex
  328.     push    ax
  329.     push    dx
  330.     push    cx
  331.     cli
  332.     mov    OSEG[curbk],ax
  333.     mov    cl,al
  334.     mov    dx,3c4h
  335.     mov    al,8
  336.     out    dx,al
  337.     inc    dl
  338.     in    al,dx
  339.     dec    dl
  340.     shl    al,1
  341.     shr    cl,1
  342.     rcr    al,1
  343.     mov    ah,al
  344.     mov    al,8
  345.     out    dx,ax
  346.     mov    dl,0cch
  347.     in    al,dx
  348.     mov    dl,0c2h
  349.     and    al,0dfh
  350.     shr    cl,1
  351.     jc    nob2
  352.     or    al,20h
  353. nob2:    out    dx,al
  354.     sti
  355.     pop    cx
  356.     pop    dx
  357.     pop    ax
  358.     ret
  359.  
  360.  
  361. _aheada::            ;Ahead Systems Ver A
  362.     push    ax
  363.     push    dx
  364.     push    cx
  365.     cli
  366.     mov    OSEG[curbk],ax
  367.     mov    ch,al
  368.     mov    dx,3ceh        ;Enable extended registers
  369.     mov    ax,200fh
  370.     out    dx,ax
  371.     mov    dl,0cch        ;bit 0
  372.     in    al,dx
  373.     mov    dl,0c2h
  374.     and    al,11011111b
  375.     shr    ch,1
  376.     jnc    skpa
  377.     or    al,00100000b
  378. skpa:    out    dx,al
  379.     mov    dl,0cfh        ;bits 1,2,3
  380.     mov    al,0
  381.     out    dx,al
  382.     inc    dx
  383.     in    al,dx
  384.     dec    dx
  385.     and    al,11111000b
  386.     or    al,ch
  387.     mov    ah,al
  388.     mov    al,0
  389.     out    dx,ax
  390.     sti
  391.     pop    cx
  392.     pop    dx
  393.     pop    ax
  394.     ret
  395.  
  396.  
  397. _aheadb::            ;Ahead Systems Ver A
  398.     push    ax
  399.     push    dx
  400.     push    cx
  401.     cli
  402.     mov    OSEG[curbk],ax
  403.     mov    ch,al
  404.     mov    dx,3ceh        ;Enable extended registers
  405.     mov    ax,200fh
  406.     out    dx,ax
  407.     mov    ah,ch
  408.     mov    cl,4
  409.     shl    ah,cl
  410.     or    ah,ch
  411.     mov    al,0dh
  412.     out    dx,ax
  413.     sti
  414.     pop    cx
  415.     pop    dx
  416.     pop    ax
  417.     ret
  418.  
  419.  
  420. _oaktech::            ;Oak Technology Inc OTI-067 and OTI-077
  421.     push    ax
  422.     push    dx
  423.     cli
  424.     mov    OSEG[curbk],ax
  425.     and    al,15
  426.     mov    ah,al
  427.     shl    al,1
  428.     shl    al,1
  429.     shl    al,1
  430.     shl    al,1
  431.     or    ah,al
  432.     mov    al,11h
  433.     mov    dx,3deh
  434.     out    dx,ax
  435.     sti
  436.     pop    dx
  437.     pop    ax
  438.     ret
  439.  
  440. _genoa::            ;GENOA GVGA
  441.     push    ax
  442.     push    dx
  443.     cli
  444.     mov    OSEG[curbk],ax
  445.     mov    ah,al
  446.     shl    al,1
  447.     shl    al,1
  448.     shl    al,1
  449.     or    ah,al
  450.     mov    al,6
  451.     or    ah,40h
  452.     mov    dx,3c4h
  453.     out    dx,ax
  454.     sti
  455.     pop    dx
  456.     pop    ax
  457.     ret
  458.  
  459. _ncr::                ;NCR 77C22E
  460.     push    ax
  461.     push    dx
  462.     cli
  463.     mov    OSEG[curbk],ax
  464.     mov    ah,al
  465.     mov    al,18h
  466.     mov    dx,3c4h
  467.     out    dx,ax
  468.     mov    ax,19h
  469.     out    dx,ax
  470.     sti
  471.     pop    dx
  472.     pop    ax
  473.     ret
  474.  
  475. _compaq::            ;Compaq
  476.     push    ax
  477.     push    dx
  478.     push    ax
  479.     cli
  480.     mov    OSEG[curbk],ax
  481.     mov    dx,3ceh
  482.     mov    ax,50fh        ;unlock extended registers
  483.     out    dx,ax
  484.     pop    ax
  485.     mov    ah,al
  486.     mov    al,45h
  487.     out    dx,ax
  488.     sti
  489.     pop    dx
  490.     pop    ax
  491.     ret
  492.  
  493. _vesa::                ;Vesa SVGA interface
  494.     push    ax
  495.     push    bx
  496.     push    dx
  497.     cli
  498.     mov    OSEG[curbk],ax
  499.     mov    dx,ax
  500.     xor    bx,bx
  501.     call    dword ptr OSEG[vesafunc]
  502.     mov    dx,OSEG[curbk]
  503.     mov    bx,1
  504.     call    dword ptr OSEG[vesafunc]
  505.     sti
  506.     pop    dx
  507.     pop    bx
  508.     pop    ax
  509.     ret
  510.  
  511. _nobank::
  512.     cli
  513.     mov    OSEG[curbk],ax
  514.     sti
  515.     ret
  516.  
  517. newbank    endp
  518.  
  519. bkadr    macro    func
  520.     mov    [func],1
  521.     mov    word ptr [bankadr],offset _&func
  522. if @Codesize
  523.     mov    word ptr [bankadr+2],seg _&func
  524. endif
  525.     endm
  526.  
  527. nojmp    macro
  528.     local    lbl
  529.     jmp    lbl
  530. lbl:
  531.     endm
  532.  
  533. dummyvesa proc    far
  534.     ret
  535. dummyvesa endp
  536.  
  537. whichvga proc    uses si di es
  538.     local    vesabuf[512]:byte    ; extra large to make up for
  539.                     ; bugs in some VESA VBE's
  540.  
  541.     cmp    [first],'FI'
  542.     jnz    gotest
  543.     mov    ax,[retval]
  544.     ret
  545. gotest:    mov    word ptr [bankadr],offset _nobank
  546. if @Codesize
  547.     mov    word ptr [bankadr+2],seg _nobank
  548. endif
  549.     mov    [vgamem],256
  550.     mov    [bksize],64
  551.     xor    ax,ax
  552.     mov    [curbk],ax
  553.     mov    [cirrus],ax
  554.     mov    [everex],ax
  555.     mov    [paradise],ax
  556.     mov    [tseng],ax
  557.     mov    [trident],ax
  558.     mov    [t8900],ax
  559.     mov    [ativga],ax
  560.     mov    [aheada],ax
  561.     mov    [aheadb],ax
  562.     mov    [oaktech],ax
  563.     mov    [video7],ax
  564.     mov    [chipstech],ax
  565.     mov    [tseng4],ax
  566.     mov    [genoa],ax
  567.     mov    [ncr],ax
  568.     mov    [compaq],ax
  569.     mov    [vesa],ax
  570.     mov    [dactype],ax
  571.     mov    [first],'FI'
  572.  
  573.     mov    si,1            ;flag for SVGA found
  574.  
  575.     mov    ax,ss
  576.     mov    es,ax
  577.     lea    di,vesabuf[0]
  578.     mov    ax,4f00h
  579.     int    10h
  580.     cmp    ax,4fh
  581.     jnz    novesa
  582.     mov    [bksize],64        ; (